
#include "StdAfx.h"
#include "LobbyEnter_Default.h"
#include "LobbyService.h"
#include "RoomManager.h"
#include "LobbyManager.h"

int LobbyEnter_Default::enter( const char* data, User* user ){
	int result = LobbyEnter_Decorator::enter( data, user );
	if( result )
		return result;	
	
	LobbyManager* lobby = LobbyService::Instance()->getLobbyManager();
	result = lobby->enterCheck( user );
	if( result )
		return result;	

 	result = lobby->add( user );
	if( result )
		return result;	

	lobby->sendLobbyInStart( user );
	lobby->sendMyInfo( user );		
	lobby->sendUserList( user );
	lobby->sendAddUser( user );

	result = lobby->enterNewUser( user );
	if( result )
		return result;

	RoomManager* roomMgr = LobbyService::Instance()->getRoomManager();
	roomMgr->sendRoomList( user );	

	result = lobby->enterLobbyEnd( user );
	if( result )
		return result;
	
	return DEFAULT_SUCCESS;
}
